package com.itheima_01.monitest.third;

import java.util.Scanner;

public class TongJiString {
    public static void main(String[] args) {
        tongJiZiFuChuan();
    }

    public static void tongJiZiFuChuan() {
        Scanner sc = new Scanner(System.in);
        int bigCount = 0;
        int smallCount = 0;
        int numCount=0;
        int otherCount = 0;
        //boolean b=true;
        System.out.println("请输入字符串(用于计算您所输入的各种字符数量！)：");
        lo:while (true){
            String s = sc.nextLine();
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) >= 65 && s.charAt(i) <= 90) {
                    bigCount++;
                    //到这一步就说明有大写字母
                }
            }
            if (bigCount != 0) {//说明有大写字母
                for (int i = 0; i < s.length(); i++) {
                    if (s.charAt(i) >= 97 && s.charAt(i) <= 122) {
                        smallCount++;
                    }
                    if (s.charAt(i) >= 48 && s.charAt(i) <= 57) {
                        numCount++;
                    }
                }
                System.out.println("大写字母的个数为:" + bigCount);
                System.out.println("小写字母的个数为:" + smallCount);
                System.out.println("数字的个数为:" + numCount);
                System.out.println("其他字符的个数为:" + (s.length()-bigCount-smallCount-numCount));
                break lo;
            }else {
                System.out.println("输入的字符串没有大写字母，请重新输入：");
            }
        }
    }
}
